package com.lili.member.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lili.common.result.Result;
import com.lili.member.bean.MemberEvaluation;
import com.lili.member.service.MemberEvaluationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/pj")
@Api(tags = "会员评价管理")
public class MemberEvaluationController {

    @Autowired
    MemberEvaluationService memberEvaluationService;

    @ApiOperation(value = "查询会员评价")
    @PostMapping("/query")
    public Result queryMemberEvaluation(@RequestBody Map map) {
        int current = 1;
        int pageSize = 10;
        if (map.get("current") != null) {
            current = Integer.parseInt(map.get("current").toString());
        }
        if (map.get("pageSize") != null) {
            pageSize = Integer.parseInt(map.get("pageSize").toString());
        }
        Page<MemberEvaluation> page = memberEvaluationService.queryByPage(current, pageSize,map);
        return Result.ok(page);
    }


    @ApiOperation(value = "删除会员评价")
    @DeleteMapping("/delete")
    public Result deleteMemberEvaluation(@RequestParam String id) {
        int rs = memberEvaluationService.delete(id);
        return rs == 1 ? Result.ok() : Result.fail();
    }

}
